<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>审核记录页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/frontEnd/images/favicon.ico">
    <link rel="stylesheet" href="/layuicms/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuicms/css/public.css" media="all" />
</head>
<body class="childrenBody">
    <!-- 查询条件开始 -->
<!--    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
        <legend>查询条件</legend>
    </fieldset>-->
<!--    <blockquote class="layui-elem-quote" style="height: 50px;">
        <form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 100px;">站细名称</label>
                    <div class="layui-input-inline" style="width: 300px">
                        <input type="text" name="typename"  autocomplete="off" class="layui-input" placeholder="请输入站细名称，例如'《延安站》站细'">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-block" style="text-align: center;">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="doSearch"> <span class="layui-icon layui-icon-search"></span> 查询</button>
                        <button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span> 重置</button>
                    </div>
                </div>
            </div>
        </form>
    </blockquote>-->
    <!--查询条件结束-->
    <!--数据表格开始-->
    <div>

        <table class="layui-hide" id="safetyAlertTypeTable" lay-filter="safetyAlertTypeTable"></table>

        <div id="safetyAlertTypeToolBar" style="display: none ;"  >
            <button type="button" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-circle"></span> 已审核记录</button>
            <button type="button" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-circle"></span> 未审核记录</button>
            <button type="button" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-circle"></span> 审核不通过</button>
        </div>
        <div id="safetyAlertTypeRowBar" style="display: none">
            <button type="button" lay-event="restPassword" class="layui-btn layui-btn-sm  layui-btn-warm"><span class="layui-icon layui-icon-refresh-3"></span> 查看</button>
        </div>
    </div>
    <!--数据表格结束-->

    <!--添加和修改弹出层开始-->
    <div style="display: none;padding: 10px;" id="addOrUpdateDiv">

        <form action="" method="post" class="layui-form" id="dataFrm" lay-filter="dataFrm">
            <div class="layui-form-item">
                <label class="layui-form-label">车站名称</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id">
                    <input type="text" name="typename"  id="typename" lay-verify="required" autocomplete="off" placeholder="请选择车站" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">站细名称</label>
                <div class="layui-input-block">
                    <input placeholder="文档名称会根据车站名称自动生成" class="layui-input" name="remarks">
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="doSubmit" id="doSubmit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

    </div>
    <!--添加和修改弹出层结束-->

</body>
<script type="text/javascript" src="/layuicms/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery','form','table','layer',],function(){
        var $ = layui.jquery;
        var form=layui.form;
        var table = layui.table;
        var layer = layui.layer;
        //初始化时间选择器
        //加载数据
        var tableIns = table.render({
             elem: '#safetyAlertTypeTable'
            ,url:'/safetyAlertType/loadAllSafetyAlertType'
            ,toolbar: '#safetyAlertTypeToolBar' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                 title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '安全类型数据表'
             ,height:'full-140'
             ,page: true
            ,cols: [ [
                 {field:'',title:'序号', type:'numbers', width:80, align: 'center', unresize: true, sort: true}
                ,{field:'typename', width:220,title:'站细审核记录' , align: 'center'}
                ,{field:'typename', width:220, title:'修改条款',align: 'center'}
                ,{field:'typename', width:150,title:'修改时间',align: 'center'}
                ,{field:'typename', width:120,title:'实施日期',align: 'center'}
                ,{field:'typename', width:120,title:'提报车站',align: 'center'}
                ,{field:'remarks', width:120,title:'提报人' , align: 'center'}
                ,{field:'remarks', width:120,title:'审核人' , align: 'center'}
                // ,{field:'remarks',  width:200,title:'修改原因',align: 'center'}
                // ,{field:'createtime', title:'创建时间'}
                ,{fixed: 'right', width:115,title:'操作', toolbar: '#safetyAlertTypeRowBar' ,align: 'center'}
            ] ]
        });
         //模糊查询
        form.on("submit(doSearch)",function (data) {
           tableIns.reload({
               where:data.field,
               page:{
                   curr:1
               }
           });
            return false;
        });
        //监听工具条事件
        table.on('toolbar(safetyAlertTypeTable)', function(obj){
            switch(obj.event){
                case 'batchDelete':
                    batchDelete();
                    break;
                case 'add':
                    openAddLayer();
                    break;
            };
        });
        //监听行工具条事件
        table.on('tool(safetyAlertTypeTable)', function(obj){
            var data = obj.data; //获得当前行数据
            switch(obj.event){
                case 'update':
                    openUpdateLayer(data);
                    break;
                case 'delete':
                    deleteSafetyAlertType(data);
                    break;
            };
        });
        var mainIndex;
        var url;

        //打开添加的弹出层
        function openAddLayer() {
            $('#typename').attr("disabled",false)
           // $('#typename').removeAttr("readonly");
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['500px','220px'],
                title:'添加站细',
                success:function () {
                    $("#dataFrm")[0].reset();
                    url="/safetyAlertType/addSafetyAlertType"
                }
            });
        }
        //打开修改弹出层
        function openUpdateLayer(data) {
            $('#typename').attr("disabled",true)
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['500px','300px'],
                title:'修改站细',
                success:function () {
                    $("#dataFrm")[0].reset();
                    form.val("dataFrm",data);
                    url="/safetyAlertType/updateSafetyAlertType"
                }
            });
        }

        //添加和修改的提交
        form.on("submit(doSubmit)",function (data) {
            $.post(url,data.field,function (res) {
                if(res.code==20000){
                    tableIns.reload();
                }
                layer.msg(res.message);
                layer.close(mainIndex);
            })
            return false
        });

        //根据ID删除
        function deleteSafetyAlertType(data) {
            layer.confirm('你确定删除【'+data.typename+'】吗?', {icon: 3, title:'提示'}, function(index){
            $.post("/safetyAlertType/deleteSafetyAlertType",{id:data.id},function (res) {
                        if(res.code==20000){
                            tableIns.reload();
                        }
                        layer.close(res.message);
                    })
                    layer.close(index);
                }
            )};
    });
</script>
</html>